<?php
namespace Plugin\Alarm\Schema;

use Plugin\Alarm\Model\RdAlarmDanger;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 隐患信息
 */
#[Schema(title: 'RdAlarmDangerSchema')]
class RdAlarmDangerSchema implements \JsonSerializable
{
    #[Property(property: 'id', title: 'id', type: 'bigint')]
    public string $id;

    #[Property(property: 'type', title: '隐患类型', type: 'tinyint')]
    public string $type;

    #[Property(property: 'stand_id', title: '站点ID', type: 'bigint')]
    public string $stand_id;

    #[Property(property: 'camera_id', title: '摄像头ID', type: 'bigint')]
    public string $camera_id;

    #[Property(property: 'addr', title: '发现位置', type: 'string')]
    public string $addr;

    #[Property(property: 'from_type', title: '来源类型1:AI隐患2:拍照识别3:人工上报', type: 'int')]
    public string $from_type;

    #[Property(property: 'severity', title: '隐患严重程度1:普通2:紧急3:非常紧急', type: 'tinyint')]
    public string $severity;

    #[Property(property: 'extra', title: '附加信息', type: 'json')]
    public string $extra;

    #[Property(property: 'status', title: '状态1:待处理2:已提交工单3:未提交工单', type: 'tinyint')]
    public string $status;

    #[Property(property: 'work_id', title: '工单ID', type: 'bigint')]
    public string $work_id;

    #[Property(property: 'created_by', title: '创建人', type: 'bigint')]
    public string $created_by;

    #[Property(property: 'updated_by', title: '更新人', type: 'bigint')]
    public string $updated_by;

    #[Property(property: 'created_at', title: '创建时间', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: '更新时间', type: 'timestamp')]
    public string $updated_at;

    public function __construct(RdAlarmDanger $model)
    {
       $this->id = $model->id;
       $this->type = $model->type;
       $this->stand_id = $model->stand_id;
       $this->camera_id = $model->camera_id;
       $this->addr = $model->addr;
       $this->from_type = $model->from_type;
       $this->severity = $model->severity;
       $this->extra = $model->extra;
       $this->status = $model->status;
       $this->work_id = $model->work_id;
       $this->created_by = $model->created_by;
       $this->updated_by = $model->updated_by;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;
    }

    public function jsonSerialize(): array
    {
        return [
            'id' => $this->id,
            'type' => $this->type,
            'stand_id' => $this->stand_id,
            'camera_id' => $this->camera_id,
            'addr' => $this->addr,
            'from_type' => $this->from_type,
            'severity' => $this->severity,
            'extra' => $this->extra,
            'status' => $this->status,
            'work_id' => $this->work_id,
            'created_by' => $this->created_by,
            'updated_by' => $this->updated_by,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at
        ];
    }
}